//
//  HeaderView.m
//  VTravel
//
//  Created by lanouhn on 16/8/1.
//  Copyright © 2016年 xiaoYu. All rights reserved.
//

#import "HeaderView.h"

@implementation HeaderView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self set_up];
    }
    return self;
}

- (void)set_up{
    
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:self.frame];
    imageView.image = [UIImage imageNamed:@"header"];
    
    imageView.userInteractionEnabled = YES;
    
    self.button = [UIButton buttonWithType:UIButtonTypeCustom];
    self.button.frame = CGRectMake(self.frame.size.width / 2 - 100, self.frame.size.height / 2 - 20, 200, 40);
    self.button.backgroundColor = kRandomColor;
    [self.button setTitle:@"登录/注册" forState:UIControlStateNormal];
    [imageView addSubview:self.button];
    
    self.headerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.frame.size.width / 2 - 40, self.frame.size.height / 2 - 60, 80, 80)];
    self.headerImageView.image = [UIImage imageNamed:@"touxiang"];
    self.headerImageView.layer.cornerRadius = 40;
    self.headerImageView.layer.masksToBounds = YES;
    [imageView addSubview:self.headerImageView];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.frame.size.width / 2 - 40, self.frame.size.height / 2 + 20, 80, 40)];
    self.nameLabel.text = @"小鱼儿";
    self.nameLabel.textAlignment = NSTextAlignmentCenter;
    [imageView addSubview:self.nameLabel];
    
    [self addSubview:imageView];
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
